<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id='app' v-cloak>
    <h2>{{message}}</h2>
    <cpn2></cpn2>
    <cpn3></cpn3>
  </div>
  <script src='../js/vue.js'></script>
  <script>
    // 1.注册组件（原有写法）
    const cpn1 = Vue.extend({
      template: `<div><h2>哈哈哈哈</h2></div>`
    });
    // 原有写法
    const cpn11 = Vue.component('cpn11', cpn1);

    // 2.使用语法糖
    const cpn2 = Vue.component('cpn2', {
      template: `<div><h2>这里是语法糖写法</h2></div>`
    })

    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello Vue'
      },
      components: {
        // 局部组件语法糖
        cpn3: {
          template: `<div><h2>这里是局部组件语法糖写法</h2></div>`
        }
      }
    })
  </script>
  <style>
    [v-cloak] {
      display: none;
    }
  </style>
</body>

</html>